package cn.t.enums.order;


import cn.t.core.enums.Enumer;
import cn.t.core.enums.base.CommonEnum;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author l
 */
@Enumer
@Getter
@AllArgsConstructor
public enum OrderTransferStatusEnum  implements CommonEnum<Integer, String> {
    NOTRANSFER(0, "未转单"),
    TRANSFERRED(1, "已转单"),
    PROCESSED(2, "已处理");

    @JsonValue
    @EnumValue
    private final Integer code;
    private final String name;
    /**
     * 根据key获取desc
     *
     * @param key 枚举值
     * @return String 描述
     */
    public static String getDescByKey(Integer key) {
        Optional<OrderTransferStatusEnum> first = Arrays.stream(values()).filter(f -> f.getCode().equals(key)).findFirst();
        if (first.isPresent()) {
            return first.get().getName();
        }
        return "";
    }
}
